﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CampaignManageAdd.ascx.cs" Inherits="TCDC_System.UserControl.CampaignManageAdd" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script type="text/javascript">

    function getValues(grid) {
        var records = grid.store.modified,
            values = [];
        for (i = 0; i < records.length; i++) {
            var dataR = grid.store.prepareRecord(records[i].data, records[i], {});
            if (!Ext.isEmptyObj(dataR)) {
                values.push(dataR);
            }
        }

        grid.save();
        return values
    }
    </script>
<ext:Window ID="WindowCampaignManageAdd" runat="server" Icon="Group" Title="Campaign Manage"
    Width="800" Height="400" AutoShow="false" Modal="true" Hidden="true" Layout="Fit">
    <TopBar>
        <ext:Toolbar ID="Toolbar1" runat="server">
            <Items>
                <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                <ext:Button ID="btnSaveRecord" runat="server" Icon="Disk" Text="Save">
                    <DirectEvents>
                        <Click OnEvent="SaveCampaign">
                            <ExtraParams>
                                <ext:Parameter Name="MemberTypeValue" Value="Ext.encode(getValues(#{GridPanelMemberType}))" Mode="Raw" />
                          
                            </ExtraParams>
                            <EventMask ShowMask="true" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Items>
        </ext:Toolbar>
    </TopBar>
    <Items>
    
        <ext:FormPanel ID="FormPanel1" runat="server" Padding="8" Frame="true" LabelWidth="150"
            MonitorValid="true" DefaultAnchor="-5">
            <Items>

                 <ext:Container ID="Container1" runat="server" Layout="Column" Height="100">
                    <Items>
                        <ext:Container ID="Container2" runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                            <Items>
                                <ext:TextField ID="txt_campaign_name_th" runat="server" FieldLabel="Campaign Name (Thai)" AnchorHorizontal="95%" />
                                <ext:TextField ID="txt_campaign_name_en" runat="server" FieldLabel="Campaign Name (Eng)" AnchorHorizontal="95%" />
                                <ext:ComboBox ID="combo_campaign_group" runat="server" FieldLabel="Campaign Group" AnchorHorizontal="95%"
                                    ValueField="campaign_group_id" DisplayField="campaign_group_name_th" SelectOnFocus="true"
                                    Mode="Local" ForceSelection="true">
                                    <Store>
                                        <ext:Store ID="StoreCampignGroup" runat="server">
                                            <Reader>
                                                <ext:JsonReader IDProperty="campign_group_id">
                                                    <Fields>
                                                        <ext:RecordField Name="campaign_group_id" />
                                                        <ext:RecordField Name="campaign_group_name_th" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                            </Items>
                        </ext:Container>
                        <ext:Container ID="Container3" runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                            <Items>
                                <ext:DateField ID="txt_begin_person" runat="server" FieldLabel="วันที่เริ่มต้น" AnchorHorizontal="95%" />
                                <ext:DateField ID="txt_end_person" runat="server" FieldLabel="วันที่สิ้นสุด" AnchorHorizontal="95%" />
                            </Items>
                        </ext:Container>
                    </Items>
                </ext:Container>

                <ext:GridPanel ID="GridPanelMemberType" runat="server" Height="200" Frame="true">
                    <Store>
                        <ext:Store ID="StoreMemberType" runat="server">
                            <Reader>
                            <ext:JsonReader IDProperty="member_type_id">
                                <Fields>
                                    <ext:RecordField Name="member_type_id" />
                                    <ext:RecordField Name="member_type_name_th" />
                                    <ext:RecordField Name="member_type_name_en" />
                                    <ext:RecordField Name="add_year" />
                                    <ext:RecordField Name="add_month" />
                                    <ext:RecordField Name="price" />
                                </Fields>
                            </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                        
                    </Store>
                    <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Header="ประเภทสมาชิก" DataIndex="member_type_name_en" Width="150" Align="Left" />

                        <ext:NumberColumn Header="ปี" DataIndex="add_year" Width="100" Align="Right">
                            <Editor>
                                <ext:NumberField ID="NumberField1" runat="server" MsgTarget="Side" />
                            </Editor>
                        </ext:NumberColumn>
                        <ext:NumberColumn Header="เดือน" DataIndex="add_month" Width="100" Align="Right">
                            <Editor>
                                <ext:NumberField ID="NumberField2" runat="server" MsgTarget="Side" />
                            </Editor>
                        </ext:NumberColumn>
                        <ext:NumberColumn Header="ราคา" DataIndex="price" Width="100" Align="Right">
                            <Editor>
                                <ext:NumberField ID="NumberField3" runat="server" MsgTarget="Side" />
                            </Editor>
                        </ext:NumberColumn>

                        </Columns>
                        </ColumnModel>
                        <Plugins>
                            <ext:EditableGrid ID="EditableGrid1" runat="server" />
                        </Plugins>
                </ext:GridPanel>
                              
            </Items>
        </ext:FormPanel>
       
               
    </Items>
</ext:Window>